1. Field of the Invention
The invention concerns systems for specifying computer-executable programs generally and more specifically concerns techniques for specifying user interfaces in such programs.
2. Description of Related Art
The user interface for a computer program defines the manner in which a user of a program interacts with the program. Most generally, the program causes the computer system to output information to an output device such as a display or a loudspeaker and then wait for input from the user. The user provides the input via an input device such as a keyboard, pointing device, or microphone, and when the program receives the input, it may respond by causing the computer system to again output information and wait for input.
Historically, there have been two main classes of user interfaces: text-based user interfaces and graphical user interfaces. In text-base user interfaces, the program outputs text to a display device and the user responds to the text output by the program by inputting text from a keyboard. In graphical user interfaces, the program outputs a graphical display that includes elements such as icons, menus, and scroll bars as well as text and the user provides input to the program by using a pointing device to manipulate the elements of the graphical user interface, as well as by inputting text from the keyboard. There are many different kinds of graphical user interfaces. Graphical user interfaces have been developed for different kinds of operating systems; in addition, there are operating system-independent graphical user interfaces and lately, new kinds of graphical user interfaces have been developed for the World Wide Web and have then been used as general-purpose graphical user interfaces.
With highly interactive programs such as word processors or spread sheets, a major part of the programming effort is dedicated to programming the user interface. That is particularly the case when the user interface is a complex graphical user interface. Various techniques have been developed over the years to reduce the amount of effort required to program a user interface. One technique is to provide the programmer with a toolkit for programming the user interface. For example, the toolkit will include functions which provide a highlevel interface for an entity in the user interface such as a scroll bar, and the programmer can use the high-level functions to define and manipulate the scroll bar instead of programming the scroll bar himself from the primitive of the graphical user interface. Another technique is to provide the programmer with an application generator for the user interface. The application generator is a program which generates skeleton code for the user interface. The programmer can then modify the skeleton as needed for his or her particular interface.
While tool kits and application generators can reduce the labor involved in programming a user interface, they cannot solve a basic problem: the user interface is simply part of the program, and any time a programmer makes a change in a program, the programmer must also be sure that he or she has made all of the changes in the user interface that are required by the change in the underlying program. For instance, if a function receives the values of its parameters from the user via an interactive user interface and the programmer adds a parameter to the function or deletes a parameter from it, the programmer must change the user interface code that provides the user interface for the function to take the change in the number of parameter values into account.
The need to make sure that changes in the user interface tracks changes in the program is lessened if the user interface is the starting point for the programming. This is the case when forms-based programming environments such as that provided by Microsoft Visual Basic are used. In such environments, the programmer designs a form and then writes code which is executed when an event occurs in the form. Even with such systems, however, it is still necessary to make sure that the code for the form is reworked when the form is redesigned and that a change in the code does not require a reworking of the form itself.
The user interface for the program automatically tracks changes in the program in programming environments where the interface used to write the program is the same as the interface the user employs to interact with the program. One example of this is that provided by interpreted languages such as LISP. In LISP, the syntax for interactively invoking a function from a terminal is exactly the same as the syntax for invoking the function within another LISP function, and as the function""s interface changes, so does the syntax for invoking it from the terminal. Unfortunately, the only user interface available to the programmer is that defined by the LISP language, and LISP code is notoriously hard to read. Other examples are provided by visual programming languages such as Prograph. It is common practice in programming environments to represent a program internally in the programming environment by means of an abstract syntax tree. With programs written in textual languages, the programming environment produces the abstract syntax tree from the text of the program; in the visual programming languages, the programmer works with a visual representation of the abstract syntax tree and modifies the program by modifying the visual representation of the abstract syntax tree. Any modification of the program thus cannot help but be reflected in the user interface. Again, the only user interface available to the programmer is the visual representation of the syntax tree. Of course, for the non-programmer user, this syntax tree interface is almost as intimidating as LISP code.
What is needed is a way of making user interfaces for programs that provides easy-to-use user interfaces that track changes in the program in the same fashion as the user interfaces for LISP or Prograph. It would be further advantageous if such user interfaces were customizable, if a given program could be easily given different kinds of user interfaces, and if a new user interface could be retrofitted to a preexisting program without changing the code of the preexisting program. It is an object of the techniques disclosed herein to provide ways of making user interfaces that have some or all of the foregoing advantages.
The techniques for making user interfaces that have these advantages include associating a plurality of interactive user interface metaphors with a description of a programming construct such as an abstract syntax tree for the programming construct and generating a specified one of the interactive user interfaces from the interactive user interface metaphor corresponding to the specified interactive user interface. A metaphor may specify a textual interactive user interface or a graphical user interface, and different metaphors may correspond to different systems for providing interactive user interfaces. The user interface may be generated when the programming construct is activated or code for the user interface may be generated when the programming construct is compiled.
In other aspects, the techniques may include modifying the interactive user interface by editing the metaphor used to generate it and using the metaphor to generate the graphical user interface from information in the description, thereby assuring that any change in the programming construct that affects the interactive graphical user interface automatically results in a corresponding change in the associated interactive user interfaces. Where the programming construct is a class, metaphors associated with the class are inherited. The interactive user interface may be used to obtain parameter values for the programming construct, and when the description of the construct is an abstract syntax tree, the parameter values are incorporated into the abstract syntax tree.